package com.wd.common.utils

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit

/**
 * 作者：马海钊
 * 时间：2024/5/22 21:01
 * 功能：
 */
object HttpUtils {
    var httpUtils: HttpUtils?=null
    init {
        val retrofit = Retrofit.Builder()
            .baseUrl("http://10.59.9.18/")
            .client(
                OkHttpClient.Builder()
                    .connectTimeout(50000, TimeUnit.SECONDS)
                    .writeTimeout(50000, TimeUnit.SECONDS)
                    .readTimeout(50000, TimeUnit.SECONDS)
                    .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                    .build()
            )
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .addConverterFactory(GsonConverterFactory.create())
            .build()
    }
}